package com.sc.es.repo;

import com.sc.es.entity.House;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author sc
 * Created on  2018/2/7
 */
public interface HouseRepo extends PagingAndSortingRepository<House,Integer>,JpaSpecificationExecutor<House> {

    @Modifying
    @Transactional
    @Query("update House as house set house.cover = :cover where house.id = :id")
    void updateCover(@Param(value = "id") Integer id, @Param(value = "cover") String cover);


    List<House> findByCityEnName(@Param("cityEnName")String cityEnName);
}
